package com.xbstar.wei.service2;

import java.net.URLEncoder;




public class WeiURL {
 private static String addMedia="https://api.weixin.qq.com/cgi-bin/media/upload?access_token=";
 private static String downMdeia="https://api.weixin.qq.com/cgi-bin/media/get?access_token=";
 public static String newsInforUrl="http://weixin.jswxfc.com:9002/xbstarcas/news/newsInfo.jsp";
 public static String newsGetArtList="http://weixin.jswxfc.com:9002/xbstarcas/news/getNewsTitle.jsp";
 public static String newsServer="http://weixin.jswxfc.com:9002";
 public static String myServer="http://weixin.jswxfc.com/xbstarcas/weixin";
 //public static String loginUrl="http://182.61.7.64/xbstarcas/weixin/login";
 public static String loginUrl="http://weixin.jswxfc.com/xbstarcas/weixin/login";
 public static String author="https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
 //群发中上传图文信息
 private static String uploadnewsMediaS="https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=";
 private static String getUserInfoByAccessTokenAndOpenidUri="https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID";
 public static String getUPloadNewsMediaUrl(){
	 
	 return uploadnewsMediaS+APPProperties.getAccess_token();
 }
 private static String snsapi_baseUrl="https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
 //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx439c9c70c3815ad0&redirect_uri=https:http://1.dazhongwei.sinaapp.com/login&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
	 public static String getAddMediaByType(String type){
		 return addMedia+APPProperties.getAccess_token()+"&type="+type;
	 }
	 public static String getDownMediaType(String mediaId) {
		 return downMdeia+APPProperties.getAccess_token()+"&media_id="+mediaId;
	}
	 /**
	  * 获得author2.0认证的链接
	  * 
	  * @param uri 用户想要获得授权的页面地址
	  * @return
	  */
	 public static String getAuthor2ByAPPidAndUri(String appid,String uri){
		 String tmp=URLEncoder.encode(uri);
		 return author.replace("APPID", appid).replace("REDIRECT_URI", tmp);
	 }
	 public static String getSnsapi_baseUrlByCode(String code) {
		return snsapi_baseUrl.replace("APPID", APPProperties.APPID).replace("SECRET", APPProperties.APPSECRET).replace("CODE", code);
	}
	 /**
	  * 返回一个满足author2.0协议的链接字符串
	  * @param urlstring 包含协议头部
	  * @return 链接字符串
	  */
	public static String getAuthor2ByUri(String urlstring) {
		return getAuthor2ByAPPidAndUri(APPProperties.APPID, urlstring);
	}
	public static String getUserInfoByAccessTokenUri(String actoken,String openid) {
		return getUserInfoByAccessTokenAndOpenidUri.replace("ACCESS_TOKEN", actoken).replace("OPENID", openid);
	}
}
